<template>
    <div class="panel-box">
        <div class="panel-header">
            <span class="panel-title">
                <span class="task-count">{{config.tasks.length}}</span>
                {{config.name}}</span>
            <div class="panel-action">
                <span v-on:click = "createTask()">+</span>
                <span>...</span>
            </div>
        </div>
        <div class="panel-body">
            <task v-for="task in config.tasks" v-bind:key="task.id" v-bind:info="task" />
        </div>
        <div class="panel-footer">
            <button class="add-task-btn" v-on:click = "createTask()">
                + 添加任务
            </button>
        </div>
        <detail-model v-bind:disable="createModelDisable"
        v-on:close="createModelDisable = true"
        v-bind:taskType="config.name"/>
    </div>

</template>

<script>
    import task from './task'
    import DetailModel from './DetailModel'
    export default {
        name: 'panel',
        components: { task,DetailModel },
        props: {
            config: {
                type: Object,
                required: true
            }
        },
        data:function(){
            return{
                createModelDisable:true
            }
        },
        methods:{
            createTask:function(){
                this.createModelDisable = false;
            }
        }
    }
</script>

<style scoped>
    .panel-box {
        width: 300px;
        min-height: 500px;
        padding: 10px;
        background-color: rgb(239, 239, 239);
        border: 1px solid rgb(230, 230, 230);
        /* float: left; */
        display: inline-block;
        margin-left: 10px;
        margin-top: 10px;
        border-radius: 5px;
    }

    .panel-header {
        height: 40px;
    }
    .task-count{
        font-weight: 400;
        height: 16px;
        width: 16px;
        border-radius: 50%;
        background-color: rgb(153, 153, 153);
        display: inline-block;
        text-align: center;
        color: white;
        line-height: 16px;
        font-size: 12px;
    }
    .panel-title {
        float: left;
        font-size: 14px;
        font-weight: bold;
    }

    .panel-action {
        float: right;
    }

    .panel-action span {
        margin-left: 10px;
    }

    .panel-footer {}

    .add-task-btn {
        width: 100%;
        height: 30px;
        font-size: 16px;
        font-weight: bold;
        background: white;
        border: none;
        border-radius: 4px;
        color: black;
    }
</style>